<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!doctype html>
<html>
<head lang="zh-CN">
	<jsp:include page="./inc/head.jsp"></jsp:include>
	<title>${pagetitle}-${appName}</title>
	<!-- css files -->
	<link href="${basePath}assets/css/login/style.css" rel='stylesheet' type='text/css' media="all" />
	<!-- /css files -->
</head>
<body>
<h1>${appName}</h1>
<div class="log">
	<div class="content1">
<%--		<div id="toggle"></div>--%>
<%--		<c:if test="${wechat.enable}">--%>
<%--			<div id="wecharqr" style="display:none;">--%>
<%--				<h2 id="wechar">微信登录</h2>--%>
<%--				<img src="${basePath}/qrcode?mic=${mic}" id="qrcode" width="61.8%" height="61.8%" alt="微信扫描二维码登录" title="微信扫描二维码登录" />--%>
<%--				<div class="clear"></div>--%>
<%--				<div id="scaninfo" class="am-text-center">支持微信扫描登录</div>--%>
<%--			</div>--%>
<%--		</c:if>--%>
		<form id="form1" method="post" action="${basePath}login">
			<h2 id="form">账号登录</h2>
			<input type="hidden" name="operate" value="loginform" />
			<input type="hidden" name="returnurl" value="${returnurl}" />
			<input type="text" class="inputtag" style="margin-left: 15%;width: 70%;margin-left: 0%;margin-right: 0%" id="name" name="name" placeholder="输入登录名" required>
			<input type="password" class="inputtag" style="margin-left: 15%;width: 70%;margin-left: 0%;margin-right: 0%" id="password" name="password" placeholder="输入你的密码">
			<div style="padding: 0%;width: 70%;margin-left: 15%;margin-right: 15%" >
				<input type="text" class="inputtag" style="margin-left: 0%;width: 65%;margin-left: 0%;margin-right: 0%" id="verificationcode"
					   name="verificationcode" placeholder="验证码">
				<img align="middle" title="点击切换验证码" class="mmid" onclick="changeImg(this)" style="width: 32%;margin-left: 0%;margin-right: 0%" alt="验证码" src="${basePath}verify">
			</div>

			<div>${message}</div>
			<div class="button-row">
				<input type="submit" class="sign-in" value="登录">
				<input type="reset" class="reset" value="重填">
				<div class="clear"></div>
			</div>
		</form>
		<div class="clear"></div>
	</div>
	<div class="clear"></div>
</div>
<div class="footer">
	<p>
		<img width="180" height="50" src="${basePath}assets/i/logo.png"><br>Copyright
		&copy; 2017.${companyName}.<a target="_blank" href="#"></a>
	</p>
</div>
<jsp:include page="./inc/foot.jsp"></jsp:include>
<script type="text/javascript">
	//add your script
	function changeImg(obj){
		$(obj).prop("src","${basePath}verify?k="+Math.random());
	}

	$(document).ready(function() {
		$("#toggle").click(function() {
			$("#wecharqr").fadeToggle();
			$("#form1").fadeToggle();
			//alert('css='+$("#toggle").css("background-position"));
			if ($("#toggle").css("background-position") == "0px 0px") {
				$("#toggle").css("background-position", "-60px 0");
			} else {
				$("#toggle").css("background-position", "0px 0px");
			}

		});
	});
	<c:if test="${wechat.enable}">
	//scaninfo

	function checker(){
		$.ajax({
			type : "post",
			url : "${basePath}QRCOdeChecker",
			dataType : "json",
			data : {
				'mic':'${mic}'
			},
			success : function(data) {
				console.info(data.flag);
				if (!data.flag){
					setTimeout('checker()',2000);
				}else{
					$('#wechar').text("二维码过期请刷新页面");
				}
			}
		});
	}
	//	setTimeout('checker()',1000);
	function startTime() {
		$.ajax({
			type : "post",
			url : "${basePath}wechatlogin",
			data : {
							'mic':'${mic}'
						},
						dataType : "json",
						success : function(data) {
							//var NowTime = new Date().getTime();
							/* var d = eval("(" + data + ")");
							 $("#scaninfo").text(d.msg);*/
							if (data.bool == false) {
								setTimeout('startTime()', 2000);
							} else {
								/* $("#scaninfo").text(d.msg);
								location.replace("${basePath}login.do?operate=wechatlogin&mcid=${mcid}");
								 */
								//$("#scaninfo").text('d.mcid='+d.mcid+',d.openId='+d.openId);
								window.location.href=data.url;
							}
						}
					});
		}
		$(document).ready(function() {
			startTime();
		});
		</c:if>
	</script>
</body>
</html>